
package com.kanjian.music.util;

import java.io.File;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;

public class ThirdPartyShareUtil {

    /**
     * 分享到新浪微博
     */
    public static void ShareToWeibo(Context context, String text, String imagePath) {
        Intent intent = new Intent();
        intent.setPackage("com.sina.weibo");
        intent.setAction(android.content.Intent.ACTION_SEND);
        intent.setType("image/*");
        intent.putExtra(Intent.EXTRA_TEXT, text);
        if (!TextUtils.isEmpty(imagePath)) {
            intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
        }
        context.startActivity(intent);
    }

    /**
     * 分享到腾讯微博
     */
    public static void ShareToTencentWeibo(Context context, String text, String imagePath) {
        Intent intent = new Intent();
        intent.setPackage("com.tencent.wblog");
        intent.setAction(android.content.Intent.ACTION_SEND);
        intent.setType("image/*");
        intent.putExtra(Intent.EXTRA_TEXT, text);
        if (!TextUtils.isEmpty(imagePath)) {
            intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
        }
        context.startActivity(intent);
    }

    /**
     * 分享到微信朋友
     */
    public static void ShareToMMFriend(Context context, String text, String imagePath) {
        Intent intent = new Intent();
        ComponentName comp = new ComponentName("com.tencent.mm",
                "com.tencent.mm.ui.tools.ShareImgUI");
        intent.setComponent(comp);
        intent.setAction(android.content.Intent.ACTION_SEND);
        intent.setType("image/*");
        intent.putExtra(Intent.EXTRA_TEXT, text);
        if (!TextUtils.isEmpty(imagePath)) {
            intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
        }
        context.startActivity(intent);
    }

    /**
     * 分享到微信朋友圈
     */
    public static void ShareToMMCircle(Context context, String text, String imagePath) {
        Intent intent = new Intent();
        ComponentName comp = new ComponentName("com.tencent.mm",
                "com.tencent.mm.ui.tools.ShareToTimeLineUI");
        intent.setComponent(comp);
        intent.setAction(android.content.Intent.ACTION_SEND);
        intent.setType("image/*");
        intent.putExtra(Intent.EXTRA_TEXT, text);
        if (!TextUtils.isEmpty(imagePath)) {
            intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
        }
        context.startActivity(intent);
    }

}
